﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace PracticeSimple.Controllers
{
    public class SecurityController : Controller
    {
        //
        // GET: /Security/

        protected override void Initialize(System.Web.Routing.RequestContext requestContext)
        {
            base.Initialize(requestContext);

            if (!requestContext.HttpContext.User.Identity.IsAuthenticated)
            {
                requestContext.HttpContext.Response.Redirect("~");
            }
        }

        public bool IsAuthenticated()
        {
            if (Session["IsAuthenticated"] != null) 
            {
                if (Convert.ToBoolean(Session["IsAuthenticated"]) == true)
                {
                    return true;
                }
            }

            return false;
        }

    }
}